package com.recursion;

public class RecursionDemo {
    /*
    递归求阶层   递归求累加    递归求斐波那契数列（生兔子） 猴子吃桃
     */
    public static void main(String[] args) {
        int result = jc(5);
        System.out.println(result);
        int sum = sum(5);
        System.out.println(sum);
        int num = get(5);
        System.out.println(num);
        int taoNum = taoNum(1);
        System.out.println(taoNum);
    }

    public static int jc(int num){
        if(num==1){
            return 1;
        }else {
            return num*jc(num-1);
        }
    }

    public static int sum(int num){
        if(num==1){
            return 1;
        }else {
            return num+sum(num-1);
        }
    }

    public static int get(int month){
        if(month==1||month==2){
            return 1;
        }else {
            return get(month-1)+get(month-2);
        }
    }

    public static int taoNum(int num){
        if(num==10){
            return 1;
        }else {
            return (taoNum(num+1)+1)*2;
        }
    }
}
